<html>

<head>
    <meta name="description" content="CSS动画制作旋转木马🦄--Alger的博客">
    <meta name="keywords"
        content="Alger,Alger的博客,Alger's blog,alger,alger的博客,html,css,vue,刘俊杰的博客,刘俊杰,liujunjie,Alger开发,Android,刘先生">

    <meta charset="utf-8" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width, initial-scale=1" />

<title>CSS动画制作旋转木马🦄 | Alger&#39;s blog</title>

<link rel="shortcut icon" href="http://www.myalger.ml/favicon.ico?v=1602725656399">

<link href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://www.myalger.ml/styles/main.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css">

<script src="https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets/highlight.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.15.10/languages/dockerfile.min.js"></script>
<script src="https://cdn.bootcss.com/highlight.js/9.15.10/languages/dart.min.js"></script>

<script src="https://cdn.jsdelivr.net/npm/moment@2.27.0/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/js/bootstrap.min.js"></script>
<!-- DEMO JS -->
<!--<script src="media/scripts/index.js"></script>-->


    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.css">
</head>

<body>
    <div class="main gt-bg-theme-color-first">
        <nav class="navbar navbar-expand-lg">
    <div class="navbar-brand">
        <img class="user-avatar" src="/images/avatar.png" alt="头像">
        <div class="site-name gt-c-content-color-first">
            Alger&#39;s blog
        </div>
    </div>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <i class="fas fa-bars gt-c-content-color-first" style="font-size: 18px"></i>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <div class="navbar-nav mr-auto" style="text-align: center">
            
                <div class="nav-item">
                    
                        <a href="/" class="menu gt-a-link">
                            首页
                        </a>
                    
                </div>
            
                <div class="nav-item">
                    
                        <a href="/archives" class="menu gt-a-link">
                            归档
                        </a>
                    
                </div>
            
                <div class="nav-item">
                    
                        <a href="/tags" class="menu gt-a-link">
                            标签
                        </a>
                    
                </div>
            
                <div class="nav-item">
                    
                        <a href="http://www.myalger.ml/about" class="menu gt-a-link">
                            关于
                        </a>
                    
                </div>
            
        </div>
        <div style="text-align: center">
            <form id="gridea-search-form" style="position: relative" data-update="1602725656399" action="/search/index.html">
                <input class="search-input" autocomplete="off" spellcheck="false" name="q" placeholder="搜索文章" />
                <i class="fas fa-search gt-c-content-color-first" style="position: absolute; top: 9px; left: 10px;"></i>
            </form>
        </div>
    </div>
</nav>

        <div class="post-container">
            <div class="post-detail gt-bg-theme-color-second">
                <article class="gt-post-content">
                    <h2 class="post-title">
                        CSS动画制作旋转木马🦄
                    </h2>
                    <div class="post-info">
                        <time class="post-time gt-c-content-color-first">
                            · 2020-02-14 ·
                        </time>
                        
                        <a href="http://www.myalger.ml/FoJvIOEID/" class="post-tags">
                            # HTML
                        </a>
                        
                        <a href="http://www.myalger.ml/Io18193yza/" class="post-tags">
                            # CSS
                        </a>
                        
                    </div>
                    <div class="post-content">
                        <p>主要用到了<code>animation</code>动画  <code>transform</code>  旋转<code>perspective</code>产生透视效果 控制好图片的距离，理解三维模型，可以很简单的做出旋转木马。</p>
<!-- more -->
<p>代码如下💡</p>
<pre><code class="language-html">&lt;style&gt;

    body{
        /* 规定元素的距离，产生3d透视效果 */
        perspective: 1000px;
        background-color: #dddddd;
    }

    section{
        width: 300px;
        height: 200px;
        margin: 300px auto;
        position: relative;
        /* 让子元素保留其相对位置 */
        transform-style: preserve-3d;
        /* 动画效果 旋转 10s 匀速 循环 */
        animation: rotate 5s linear infinite;
    }

    /* 旋转 */
    @keyframes rotate{
        0%{
            transform: rotateY(0deg) rotate(0);
        }
        100%{
            transform: rotateY(360deg) rotate(0);
        }
    }

    section div{
        font-size: 40px;
        text-align: center;
        color: white;
        width: 100%;
        height: 100%;
        position: absolute;
        top:0;
        left: 0;
        background: url(&quot;https://i0.hdslb.com/bfs/sycp/creative_img/202002/89a3a2fca520c8f6df187878e47af032.jpg@1100w_484h_1c_100q.jpg&quot;) no-repeat;
    }


    section div:nth-child(1){
        transform: translateZ(300px);
    }

    section div:nth-child(2){
        transform: rotateY(60deg) translateZ(300px);
    }
    section div:nth-child(3){
        transform: rotateY(120deg) translateZ(300px);
    }
    section div:nth-child(4){
        transform: rotateY(180deg) translateZ(300px);
    }
    section div:nth-child(5){
        transform: rotateY(240deg) translateZ(300px);
    }

    section div:nth-child(6){
        transform: rotateY(300deg) translateZ(300px);
    }

&lt;/style&gt;


&lt;body&gt;
    &lt;section&gt;
        &lt;div&gt;1&lt;/div&gt;
        &lt;div&gt;2&lt;/div&gt;
        &lt;div&gt;3&lt;/div&gt;
        &lt;div&gt;4&lt;/div&gt;
        &lt;div&gt;5&lt;/div&gt;
        &lt;div&gt;6&lt;/div&gt;
    &lt;/section&gt;
&lt;/body&gt;

</code></pre>
<blockquote>
<p>是不是很简单呢！</p>
<p>下一篇见🧲</p>
</blockquote>

                    </div>
                </article>
            </div>

            
            <div class="next-post">
                <div class="next gt-c-content-color-first">下一篇</div>
                <a href="http://www.myalger.ml/HTMW_GE/" class="post-title gt-a-link">
                    HTML+CSS 模仿商品展示 💻
                </a>
            </div>
            

            
            <span id="/CSS_EF/" class="leancloud_visitors" data-flag-title="CSS动画制作旋转木马🦄">
                <em class="post-meta-item-text">阅读量 </em>
                <i class="leancloud-visitors-count">0</i>
            </span>
            

            

            
            <script src='https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js'></script>

<style>
	div#vcomments{
		width:100%;
		max-width: 1000px;
		padding: 2.5%
	}
</style>


	<div id="vcomments"></div>

<script>
	new Valine({
		el: '#vcomments',
		appId: 'zSod8O6f9ppLFYxB5PgGNotJ-gzGzoHsz',
		appKey: 'zPFYmL2RAeARE6sTWFnHfJg7',
		avatar: 'retro',
		pageSize: 10,
		recordIp: true,
		placeholder: 'Just Go Go',
		visitor: true,
	});
</script>

            

            <div class="site-footer gt-c-content-color-first">
    <div class="slogan gt-c-content-color-first">春风得意马蹄疾,一日看尽长安花.
</div>
    <div class="social-container">
        
            
        
            
        
            
        
            
        
            
        
            
        
    </div>
    <div class="footer-info">
        Powered by <a href="https://github.com/getgridea/gridea" target="_blank">Gridea</a>
    </div>
    <div>
        Theme by <a href="https://imhanjie.com/" target="_blank">imhanjie</a>, Powered by <a
                href="https://github.com/getgridea/gridea" target="_blank">Gridea | <a href="http://www.myalger.ml/atom.xml" target="_blank">RSS</a></a>
    </div>
</div>

<script>
  hljs.initHighlightingOnLoad()
</script>

        </div>
    </div>
</body>

</html>